Skip to content

fix(pgsql-test): fail the harness when seeding fails - #1774

Merged
pyramation merged 2 commits into
mainfrom
fix/pgsql-test-seed-failures
Aug 24, 2026
Merged

fix(pgsql-test): fail the harness when seeding fails#1774
pyramation merged 2 commits into
mainfrom
fix/pgsql-test-seed-failures

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

getConnections caught every error from the seed phase, logged it to stderr, and handed the caller working clients on a half-built database:

} catch (error) {
  process.stderr.write(`[pgsql-test] Seed error (continuing):\n${formatted}\n`);
  // continue without teardown to allow caller-managed lifecycle
}

So a failed fixture deploy — the pgpm deploy that stands the schema up, or any seed.fn/seed.sqlfile — is not a setup failure but a passing setup, and the suite reports relation "…" does not exist in each test instead of the one error that caused it. Jest buries the stderr line above the first failure, which is how a single broken deploy reads as twenty unrelated mysteries.

Now the seed phase is fatal: stderr formatting is kept, the ephemeral database is torn down (its own failure deliberately swallowed with a comment, so it can't mask the seed error), and the original error is rethrown as the cause:

process.stderr.write(`[pgsql-test] Seed failed:\n${formatted}\n`);
try { await teardown(); } catch { /* abandoning this db anyway */ }
throw new Error(`[pgsql-test] Seed failed:\n${formatted}`, { cause: error });

Two tests cover it (a throwing adapter and invalid seed SQL). Measured before changing: no suite in this package, nor the db-heavy suites in constructive-db (metaschema, introspection, database-jobs, app provisioning), was riding on a swallowed seed failure — patched and unpatched runs are identical, and the rethrow was verified to actually fire with a deliberately-throwing adapter.

Link to Devin session: https://app.devin.ai/sessions/47477486a4fd45e684bd663b7007a629
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR hardens the pgsql-test harness so that when seeding fails, the partially-created test database and its connection pool are cleaned up before the seed error is rethrown, and it adds tests for that seed-failure path.

Files Change
postgres/pgsql-test/src/connect.ts On seed failure, tears down the pool/database (best-effort) before rethrowing the seed error, making the harness fail fast instead of leaking an orphan database.
postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts Adds tests asserting the harness fails and cleans up when seeding fails.

Reviewed commit: 2fcfd0c

@blacksmith-sh

This comment has been minimized.

@pyramation
pyramation merged commit a70a0fa into main Aug 24, 2026
20 checks passed
@pyramation
pyramation deleted the fix/pgsql-test-seed-failures branch August 24, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant